package com.google.android.exoplayer2;

import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.audio.AudioProcessor;
import java.util.ArrayList;
import o.abt;
import o.acf;
import o.adf;
import o.adn;
import o.ahb;
import o.ahh;
import o.ahk;
import o.ajk;
import o.ajn;
import o.amz;
import o.anu;
import o.anz;
import o.aok;

public class DefaultRenderersFactory implements abt {
    private final Context ˊ;
    private boolean ˋ;
    private long ˎ = 5000;
    private int ˏ = 0;
    @Nullable
    private adf<adn> ॱ;
    private ahb ॱॱ = ahb.ˎ;

    public DefaultRenderersFactory(Context context) {
        this.ˊ = context;
    }

    public Renderer[] ˎ(Handler handler, anz o_anz, acf o_acf, ajn o_ajn, ahh o_ahh, @Nullable adf<adn> o_adf_o_adn) {
        adf o_adf;
        if (o_adf_o_adn == null) {
            o_adf = this.ॱ;
        } else {
            adf<adn> o_adf_o_adn2 = o_adf_o_adn;
        }
        ArrayList arrayList = new ArrayList();
        ˊ(this.ˊ, this.ˏ, this.ॱॱ, o_adf, this.ˋ, handler, o_anz, this.ˎ, arrayList);
        ॱ(this.ˊ, this.ˏ, this.ॱॱ, o_adf, this.ˋ, ˏ(), handler, o_acf, arrayList);
        ˋ(this.ˊ, o_ajn, handler.getLooper(), this.ˏ, arrayList);
        ˏ(this.ˊ, o_ahh, handler.getLooper(), this.ˏ, arrayList);
        ॱ(this.ˊ, this.ˏ, arrayList);
        ˊ(this.ˊ, handler, this.ˏ, arrayList);
        return (Renderer[]) arrayList.toArray(new Renderer[arrayList.size()]);
    }

    protected void ˊ(Context context, int i, ahb o_ahb, @Nullable adf<adn> o_adf_o_adn, boolean z, Handler handler, anz o_anz, long j, ArrayList<Renderer> arrayList) {
        arrayList.add(new anu(context, o_ahb, j, o_adf_o_adn, z, handler, o_anz, 50));
        if (i != 0) {
            int i2;
            int size = arrayList.size();
            if (i == 2) {
                i2 = size - 1;
            } else {
                i2 = size;
            }
            try {
                int i3 = i2 + 1;
                ArrayList<Renderer> arrayList2 = arrayList;
                arrayList2.add(i2, (Renderer) Class.forName("com.google.android.exoplayer2.ext.vp9.LibvpxVideoRenderer").getConstructor(new Class[]{Boolean.TYPE, Long.TYPE, Handler.class, anz.class, Integer.TYPE}).newInstance(new Object[]{Boolean.valueOf(true), Long.valueOf(j), handler, o_anz, Integer.valueOf(50)}));
                amz.ॱ("DefaultRenderersFactory", "Loaded LibvpxVideoRenderer.");
            } catch (ClassNotFoundException e) {
            } catch (Throwable e2) {
                throw new RuntimeException("Error instantiating VP9 extension", e2);
            }
        }
    }

    /* JADX WARNING: inconsistent code. */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    protected void ॱ(android.content.Context r11, int r12, o.ahb r13, @androidx.annotation.Nullable o.adf<o.adn> r14, boolean r15, com.google.android.exoplayer2.audio.AudioProcessor[] r16, android.os.Handler r17, o.acf r18, java.util.ArrayList<com.google.android.exoplayer2.Renderer> r19) {
        /*
        r10 = this;
        r1 = new o.aco;
        r8 = o.abz.ˏ(r11);
        r2 = r11;
        r3 = r13;
        r4 = r14;
        r5 = r15;
        r6 = r17;
        r7 = r18;
        r9 = r16;
        r1.<init>(r2, r3, r4, r5, r6, r7, r8, r9);
        r0 = r19;
        r0.add(r1);
        if (r12 != 0) goto L_0x001b;
    L_0x001a:
        return;
    L_0x001b:
        r3 = r19.size();
        r1 = 2;
        if (r12 != r1) goto L_0x0024;
    L_0x0022:
        r3 = r3 + -1;
    L_0x0024:
        r1 = "com.google.android.exoplayer2.ext.opus.LibopusAudioRenderer";
        r1 = java.lang.Class.forName(r1);	 Catch:{ ClassNotFoundException -> 0x00de, Exception -> 0x00e2 }
        r2 = 3;
        r2 = new java.lang.Class[r2];	 Catch:{ ClassNotFoundException -> 0x00de, Exception -> 0x00e2 }
        r4 = 0;
        r5 = android.os.Handler.class;
        r2[r4] = r5;	 Catch:{ ClassNotFoundException -> 0x00de, Exception -> 0x00e2 }
        r4 = 1;
        r5 = o.acf.class;
        r2[r4] = r5;	 Catch:{ ClassNotFoundException -> 0x00de, Exception -> 0x00e2 }
        r4 = 2;
        r5 = com.google.android.exoplayer2.audio.AudioProcessor[].class;
        r2[r4] = r5;	 Catch:{ ClassNotFoundException -> 0x00de, Exception -> 0x00e2 }
        r1 = r1.getConstructor(r2);	 Catch:{ ClassNotFoundException -> 0x00de, Exception -> 0x00e2 }
        r2 = 3;
        r2 = new java.lang.Object[r2];	 Catch:{ ClassNotFoundException -> 0x00de, Exception -> 0x00e2 }
        r4 = 0;
        r2[r4] = r17;	 Catch:{ ClassNotFoundException -> 0x00de, Exception -> 0x00e2 }
        r4 = 1;
        r2[r4] = r18;	 Catch:{ ClassNotFoundException -> 0x00de, Exception -> 0x00e2 }
        r4 = 2;
        r2[r4] = r16;	 Catch:{ ClassNotFoundException -> 0x00de, Exception -> 0x00e2 }
        r1 = r1.newInstance(r2);	 Catch:{ ClassNotFoundException -> 0x00de, Exception -> 0x00e2 }
        r1 = (com.google.android.exoplayer2.Renderer) r1;	 Catch:{ ClassNotFoundException -> 0x00de, Exception -> 0x00e2 }
        r2 = r3 + 1;
        r0 = r19;
        r0.add(r3, r1);	 Catch:{ ClassNotFoundException -> 0x0104, Exception -> 0x00e2 }
        r1 = "DefaultRenderersFactory";
        r3 = "Loaded LibopusAudioRenderer.";
        o.amz.ॱ(r1, r3);	 Catch:{ ClassNotFoundException -> 0x0104, Exception -> 0x00e2 }
        r3 = r2;
    L_0x0061:
        r1 = "com.google.android.exoplayer2.ext.flac.LibflacAudioRenderer";
        r1 = java.lang.Class.forName(r1);	 Catch:{ ClassNotFoundException -> 0x00eb, Exception -> 0x00ef }
        r2 = 3;
        r2 = new java.lang.Class[r2];	 Catch:{ ClassNotFoundException -> 0x00eb, Exception -> 0x00ef }
        r4 = 0;
        r5 = android.os.Handler.class;
        r2[r4] = r5;	 Catch:{ ClassNotFoundException -> 0x00eb, Exception -> 0x00ef }
        r4 = 1;
        r5 = o.acf.class;
        r2[r4] = r5;	 Catch:{ ClassNotFoundException -> 0x00eb, Exception -> 0x00ef }
        r4 = 2;
        r5 = com.google.android.exoplayer2.audio.AudioProcessor[].class;
        r2[r4] = r5;	 Catch:{ ClassNotFoundException -> 0x00eb, Exception -> 0x00ef }
        r1 = r1.getConstructor(r2);	 Catch:{ ClassNotFoundException -> 0x00eb, Exception -> 0x00ef }
        r2 = 3;
        r2 = new java.lang.Object[r2];	 Catch:{ ClassNotFoundException -> 0x00eb, Exception -> 0x00ef }
        r4 = 0;
        r2[r4] = r17;	 Catch:{ ClassNotFoundException -> 0x00eb, Exception -> 0x00ef }
        r4 = 1;
        r2[r4] = r18;	 Catch:{ ClassNotFoundException -> 0x00eb, Exception -> 0x00ef }
        r4 = 2;
        r2[r4] = r16;	 Catch:{ ClassNotFoundException -> 0x00eb, Exception -> 0x00ef }
        r1 = r1.newInstance(r2);	 Catch:{ ClassNotFoundException -> 0x00eb, Exception -> 0x00ef }
        r1 = (com.google.android.exoplayer2.Renderer) r1;	 Catch:{ ClassNotFoundException -> 0x00eb, Exception -> 0x00ef }
        r2 = r3 + 1;
        r0 = r19;
        r0.add(r3, r1);	 Catch:{ ClassNotFoundException -> 0x0101, Exception -> 0x00ef }
        r1 = "DefaultRenderersFactory";
        r3 = "Loaded LibflacAudioRenderer.";
        o.amz.ॱ(r1, r3);	 Catch:{ ClassNotFoundException -> 0x0101, Exception -> 0x00ef }
    L_0x009d:
        r1 = "com.google.android.exoplayer2.ext.ffmpeg.FfmpegAudioRenderer";
        r1 = java.lang.Class.forName(r1);	 Catch:{ ClassNotFoundException -> 0x00db, Exception -> 0x00f8 }
        r3 = 3;
        r3 = new java.lang.Class[r3];	 Catch:{ ClassNotFoundException -> 0x00db, Exception -> 0x00f8 }
        r4 = 0;
        r5 = android.os.Handler.class;
        r3[r4] = r5;	 Catch:{ ClassNotFoundException -> 0x00db, Exception -> 0x00f8 }
        r4 = 1;
        r5 = o.acf.class;
        r3[r4] = r5;	 Catch:{ ClassNotFoundException -> 0x00db, Exception -> 0x00f8 }
        r4 = 2;
        r5 = com.google.android.exoplayer2.audio.AudioProcessor[].class;
        r3[r4] = r5;	 Catch:{ ClassNotFoundException -> 0x00db, Exception -> 0x00f8 }
        r1 = r1.getConstructor(r3);	 Catch:{ ClassNotFoundException -> 0x00db, Exception -> 0x00f8 }
        r3 = 3;
        r3 = new java.lang.Object[r3];	 Catch:{ ClassNotFoundException -> 0x00db, Exception -> 0x00f8 }
        r4 = 0;
        r3[r4] = r17;	 Catch:{ ClassNotFoundException -> 0x00db, Exception -> 0x00f8 }
        r4 = 1;
        r3[r4] = r18;	 Catch:{ ClassNotFoundException -> 0x00db, Exception -> 0x00f8 }
        r4 = 2;
        r3[r4] = r16;	 Catch:{ ClassNotFoundException -> 0x00db, Exception -> 0x00f8 }
        r1 = r1.newInstance(r3);	 Catch:{ ClassNotFoundException -> 0x00db, Exception -> 0x00f8 }
        r1 = (com.google.android.exoplayer2.Renderer) r1;	 Catch:{ ClassNotFoundException -> 0x00db, Exception -> 0x00f8 }
        r3 = r2 + 1;
        r0 = r19;
        r0.add(r2, r1);	 Catch:{ ClassNotFoundException -> 0x00db, Exception -> 0x00f8 }
        r1 = "DefaultRenderersFactory";
        r2 = "Loaded FfmpegAudioRenderer.";
        o.amz.ॱ(r1, r2);	 Catch:{ ClassNotFoundException -> 0x00db, Exception -> 0x00f8 }
        goto L_0x001a;
    L_0x00db:
        r1 = move-exception;
        goto L_0x001a;
    L_0x00de:
        r1 = move-exception;
        r1 = r3;
    L_0x00e0:
        r3 = r1;
        goto L_0x0061;
    L_0x00e2:
        r1 = move-exception;
        r2 = new java.lang.RuntimeException;
        r3 = "Error instantiating Opus extension";
        r2.<init>(r3, r1);
        throw r2;
    L_0x00eb:
        r1 = move-exception;
        r1 = r3;
    L_0x00ed:
        r2 = r1;
        goto L_0x009d;
    L_0x00ef:
        r1 = move-exception;
        r2 = new java.lang.RuntimeException;
        r3 = "Error instantiating FLAC extension";
        r2.<init>(r3, r1);
        throw r2;
    L_0x00f8:
        r1 = move-exception;
        r2 = new java.lang.RuntimeException;
        r3 = "Error instantiating FFmpeg extension";
        r2.<init>(r3, r1);
        throw r2;
    L_0x0101:
        r1 = move-exception;
        r1 = r2;
        goto L_0x00ed;
    L_0x0104:
        r1 = move-exception;
        r1 = r2;
        goto L_0x00e0;
        */
        throw new UnsupportedOperationException("Method not decompiled: com.google.android.exoplayer2.DefaultRenderersFactory.ॱ(android.content.Context, int, o.ahb, o.adf, boolean, com.google.android.exoplayer2.audio.AudioProcessor[], android.os.Handler, o.acf, java.util.ArrayList):void");
    }

    protected void ˋ(Context context, ajn o_ajn, Looper looper, int i, ArrayList<Renderer> arrayList) {
        arrayList.add(new ajk(o_ajn, looper));
    }

    protected void ˏ(Context context, ahh o_ahh, Looper looper, int i, ArrayList<Renderer> arrayList) {
        arrayList.add(new ahk(o_ahh, looper));
    }

    protected void ॱ(Context context, int i, ArrayList<Renderer> arrayList) {
        arrayList.add(new aok());
    }

    protected void ˊ(Context context, Handler handler, int i, ArrayList<Renderer> arrayList) {
    }

    protected AudioProcessor[] ˏ() {
        return new AudioProcessor[0];
    }
}
